--[[ EMA template --]] Settings= { Name = "EMA", -- indicator name ln=20, -- period line= { { Name = "EMA", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,255) } } } function Init() ema = {} return 1 end function OnCalculate(index) ln = Settings.ln if index-1 < 1 then ema[index] = C(index) else ema[index] = (ema[index-1]*(ln-1) + C(index))/ln end return ema[index] end